package 多线程;
import java.util.concurrent.TimeUnit;
public class T3{
    public static void main(String[] args) {
        //多线程 方法一
//        Thread t1 =new Thread(){
//            @Override
//            public void run(){
//               this.setName("one thread");
//               System.out.println(this.getName());
//            }
//        };
//        t1.setName("one dfgThread");
//        t1.start();
        //多线程 方法二，实现接口，实现Thread作为参数
        var t2 = new Runnable() {
            @Override
            public void run() {
                String n = Thread.currentThread().getName();
                System.out.println(n);
            }
        };
        var t22 = new Thread(t2, "two thread");
       // t22.setName("two2222 thread");
        t22.start();

        try {
            TimeUnit.SECONDS.sleep(5);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("项目输出完毕");

    }
}
